home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Bus / T-Z / VCR+(app+src) Folder / Sources / validateEntry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-17  |  1.9 KB  |  84 lines  |  [TEXT/KAHL]

  1. #include "VCRplus.h"
  2.  
  3. extern    vcrInfo    myVCR;
  4. extern    long        CODE_VALUE;
  5.  
  6. Boolean validateEntry(short entryType)
  7. {
  8.     unsigned long        tempLong, tempLong2;
  9.     Str32    scratch;
  10.     
  11.     if (entryType == DECODE)
  12.     {
  13.         SetDText(dlgCHANNEL,"\p");
  14.         SetDText(dlgSTARTTIME,"\p");
  15.         SetDText(dlgDURATION,"\p");
  16.         
  17.         GetDText(dlgPLUSCODE, scratch);
  18.         StringToNum(scratch, &tempLong);
  19.     
  20.         if( (tempLong<1) || (tempLong>999999L) )
  21.         { SetDText(19,"\pCannot process that VCR plus code (must be <= 6 digits)!"); return FALSE; }
  22.  
  23.         myVCR.code = tempLong;
  24.         CODE_VALUE = KEY001;
  25.     }
  26.     else
  27.     {
  28.         SetDText(dlgPLUSCODE,"\p");
  29.  
  30.         GetDText(dlgCHANNEL, scratch);
  31.         StringToNum(scratch, &tempLong);
  32.     
  33.         if( (tempLong<1) || (tempLong>48) )
  34.         { SetDText(19,"\pInvalid channel number"); return FALSE; }
  35.         
  36.         myVCR.channel = tempLong;
  37.     
  38.         GetDText(dlgSTARTTIME, scratch);
  39.         StringToNum(scratch, &tempLong);
  40.     
  41.         tempLong2 = tempLong % 100;
  42.         if((tempLong2 != 0) && (tempLong2 != 30))
  43.         { SetDText(19,"\pStart time must be on an hour or half hour!"); return FALSE; }
  44.     
  45.         if((tempLong < 0) || (tempLong > 2330))
  46.         { SetDText(19,"\pStart time must be in format: 1800 for 6pm"); return FALSE; }
  47.         
  48.         myVCR.startTime = tempLong;
  49.     
  50.         GetDText(dlgDURATION, scratch);
  51.         StringToNum(scratch, &tempLong);
  52.     
  53.         tempLong2 = tempLong % 30;
  54.         if((tempLong2!=0) || (tempLong<30) || (tempLong>300))
  55.         { SetDText(19,"\pSorry, I cant process that program length\n"); return FALSE; }
  56.         
  57.         myVCR.duration = tempLong;
  58.         CODE_VALUE = KEY002;
  59.     }
  60.     
  61.     GetDText(dlgMONTH, scratch);
  62.     StringToNum(scratch, &tempLong);
  63.  
  64.     if ((tempLong>12) || (tempLong<1))
  65.     { SetDText(19,"\pInvalid month (must be 1-12)"); return FALSE; }
  66.     
  67.     myVCR.month = tempLong;
  68.  
  69.     GetDText(dlgDAY, scratch);
  70.     StringToNum(scratch, &tempLong);
  71.  
  72.     if((tempLong<1) || (tempLong>31) )
  73.     { SetDText(19,"\pInvalid day (must be 1-31)"); return FALSE; }
  74.     
  75.     myVCR.day = tempLong;
  76.  
  77.     GetDText(dlgYEAR, scratch);
  78.     StringToNum(scratch, &tempLong);
  79.  
  80.     myVCR.year = tempLong % 100;
  81.  
  82.     return TRUE;
  83. }
  84.